local ITEM_SUGAR_CANE = 5466
local posTable = {
	{x = -1, y = -1}, {x = 0, y =  -1},
	{x = 1, y = -1}, {x = 1, y = 0},
	{x = 1, y = 1}, {x = 0, y = 1},
	{x = -1, y = 1}, {x = -1, y = 0}
} -- 8
function burningSugarCane(pos)
	local POS
	local t
	for _, table_pos in pairs(posTable) do
		POS = {x = pos.x + table_pos.x, y = pos.y + table_pos.y, z = pos.z} 
		
		for a = 1, 10 do
			POS.stackpos = a
			t = getThingFromPos(POS)
			if t.itemid == ITEM_SUGAR_CANE then
				addEvent(burningSugarCane, 2*1000, {x = POS.x, y = POS.y, z = POS.z})
				doTransformItem(t.uid, t.itemid -1)
				doDecayItem(t.uid)
				break
			end
		end
	end
	return true
end

function onUse(cid, item, frompos, item2, topos)
	if (item2.itemid == ITEM_SUGAR_CANE) then
		if (math.random(0, 20) == 1) then
			doPlayerAddHealth(cid, -5)
			doSendMagicEffect(frompos, CONST_ME_EXPLOSIONAREA)
			doRemoveItem(item.uid)
			return true
		end
		
		return burningSugarCane({x = topos.x, y = topos.y, z = topos.z})
	end
	return false
end